<script setup>
import { reactive, ref, onMounted } from 'vue'

const tableData = [{
  date: '2016-05-03',
  name: 'Tom',
  address: 'No. 189, Grove St, Los Angeles',
}]

let formDialogVisible = ref(false)
let formDialogTitle = ref('')
const form = reactive({
  value: ''
})

onMounted(() => {
})

function handleAdd() {
  formDialogVisible.value = true
  formDialogTitle.value = '新增'
}

function close() {
  formDialogVisible.value = false
}
</script>
<script>
export default { name: 'User' }
</script>

<template>
  <div>
    <div>
      <el-button icon="Plus" @click="handleAdd">新增</el-button>
      <el-button icon="Refresh">刷新</el-button>
    </div>
    <el-table :data="tableData" stripe class="m-t-10" style="width: 100%">
      <el-table-column prop="date" label="日期" />
      <el-table-column prop="name" label="名称" />
      <el-table-column prop="address" label="地址" />
      <el-table-column label="操作">
        <template #default>
          <el-button link type="primary">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination background layout="prev, pager, next" :total="1000" class="m-t-10" />

    <!-- 新增、编辑的弹窗 -->
    <el-dialog v-model="formDialogVisible" :title="formDialogTitle" :close-on-click-modal="false" width="700px"
      :before-close="close">
      <el-form :model="form" label-width="80px">
        <el-form-item label="input">
          <el-input v-model="form.value" />
        </el-form-item>
      </el-form>

      <template #footer>
        <span>
          <el-button @click="close">取消</el-button>
          <el-button type="primary">提交</el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>